package SortMethod;

import SortHelper.SortHelper;

public class PartitionTryWro {

    public static int partition(Integer[] arr,int l,int r){
        int p = l;
        for (int i = l+1; i <= r; i++) {
            if (arr[p] > arr[i]){
                SortHelper.swap(arr,p,i);
                p = i;
            } else {
                SortHelper.swap(arr,i,r--);
                i--;
            }
        }
        return p;
    }

    public static void main(String[] args) {
        Integer[] arr = {2, 3, 1, 3, -3, -2, 6, -5, -1, 1};
        int p = partition(arr,0,arr.length-1);
        System.out.println(p);
        for (int n : arr){
            System.out.printf("%d ",n);
        }
    }
}
